]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/icon: Only get resource-scale after peeking theme node
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 4 Aug 2021 17:46:34 +0000 (19:46 +0200)
committerMarge Bot <marge-bot@gnome.org>
Thu, 5 Aug 2021 10:03:51 +0000 (10:03 +0000)
If an actor is not on any stage view, then it doesn't have a valid
resource scale, which will hit an assert later.

When that is the case (for example when running headless), we expect
that there is no valid theme node (yet) either, so simply moving
the clutter_actor_get_resource_scale() call after peeking at the
theme node is enough to avoid the crash.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4522

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1935>

src/st/st-icon.c

index 49cdfec48a3be851383e1f064866e61c0f8e6aff..71ba1b6b3683a9f44128f0426c9508911e214f8a 100644 (file)
@@ -487,8 +487,6 @@ st_icon_update (StIcon *icon)
       return;
     }
 
-  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (icon));
-
   theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
   if (theme_node == NULL)
     return;
@@ -496,6 +494,8 @@ st_icon_update (StIcon *icon)
   if (priv->icon_size <= 0)
     return;
 
+  resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (icon));
+
   stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
   context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
   g_object_get (context, "scale-factor", &paint_scale, NULL);